package com.hexacta.hrs.repositories.staffing.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.hexacta.hrs.domain.staffing.assignment.EmployeeAssignment;
import com.hexacta.hrs.repositories.staffing.EmployeeAssignmentRepository;

public class EmployeeAssignmentRepositoryHibernateTemplateImpl extends HibernateDaoSupport implements  EmployeeAssignmentRepository{
	public void saveOrUpdate(Object o) {
        this.getHibernateTemplate().saveOrUpdate(o);
        return;
    }
    
    public void delete(EmployeeAssignment assignment) {
        this.getHibernateTemplate().delete(assignment);
    }
    
    public EmployeeAssignment findById(long id) {
    	EmployeeAssignment EmployeeAssignment = (EmployeeAssignment) this.getHibernateTemplate().get(EmployeeAssignment.class, Long.valueOf(id));
    	return EmployeeAssignment;
    }
    
    @SuppressWarnings("unchecked")
    public List<EmployeeAssignment> findByName(String name) {
    	List<EmployeeAssignment> EmployeeAssignments = this.getHibernateTemplate().find("from " + EmployeeAssignment.class.getSimpleName() + " where name = '" + name + "'");
    	return EmployeeAssignments;
    }
    
    @SuppressWarnings("unchecked")
	public List<EmployeeAssignment> findAll() {
    	List<EmployeeAssignment> projects = this.getHibernateTemplate().find("from " + EmployeeAssignment.class.getSimpleName());
    	return projects;
    }
}
